option(USE_LIB_MATHFUNCTIONS "checkout " ON)

if(USE_LIB_MATHFUNCTIONS)
    add_subdirectory(MathFunctions)
    add_file(QT_THIRD_LIBS MathFunc)
endif()

# 注意变量间的调用顺序
# cmake:在各级子项目(目录)之间共享变量

# set
# set(ICD_LIBRARY "${PROJECT_BINARY_DIR}/lib" CACHE INTERNAL "Share Val")
# "Share Val" 对变量的描述说明,不能省略
# 其他地方使用MESSAGE(STATUS "ICD_LIBRARY :${ICD_LIBRARY}")

# set_property/get_property
# set_property(GLOBAL PROPERTY INCLUDE "${CMAKE_CURRENT_LIST_DIR}/include")
# 先调用get_property将这个property读取到一个变量中(variable)INCLUDE
# get_property(MINCLUDE GLOBAL PROPERTY INCLUDE ) 
# 显示MINCLUDE
# MESSAGE(STATUS "${MINCLUDE}")

# 添加库头文件目录
# 注意：要放在add_executable、add_library前边才有效
# include_directories("a/b/c/")
# include_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib/xxx/include)

# 添加库文件目录
# link_directories(${CMAKE_CURRENT_SOURCE_DIR}/dll)


# 链接库文件
# 直接是全路径link_libraries(${CMAKE_CURRENT_SOURCE_DIR}/dll/libusb.a)
# 链接多个link_libraries(${CMAKE_CURRENT_SOURCE_DIR}/dll/libusb.so
#                       ${CMAKE_CURRENT_SOURCE_DIR}/dll/libpt.so)


# 注意：要放在add_library后边才有效
# target_include_directories(lib
#     INTERFACE      # 权限控制，类比：public/private/protected
#         ${CMAKE_CURRENT_SOURCE_DIR}/
# )

# 调用第三方lib/dll
# 设置target名字为dll，并且是一个外部导入的lib
# GLOBAL选项可以将target的作用域变为全局，默认是只在目录内可见
# add_library(dll SHARED IMPORTED GLOBAL)
# # 设置target dll的详细属性，dll/lib 不区分debug/release的情况
# set_target_properties(dll PROPERTIES
#     # 指向lib，windows必须设置此项
#     IMPORTED_IMPLIB ${CMAKE_CURRENT_LIST_DIR}/dll.lib
#     # 指向dll、so等
#     IMPORTED_LOCATION ${CMAKE_CURRENT_LIST_DIR}/dll.dll
# )
# 设置debug/release
# set_target_properties(dll PROPERTIES
#     IMPORTED_IMPLIB_DEBUG ${CMAKE_CURRENT_LIST_DIR}/dll_debug.lib
#     IMPORTED_IMPLIB_RELEASE ${CMAKE_CURRENT_LIST_DIR}/dll_release.lib
#     IMPORTED_LOCATION_DEBUG ${CMAKE_CURRENT_LIST_DIR}/dll_debug.dll
#     IMPORTED_LOCATION_RELEASE ${CMAKE_CURRENT_LIST_DIR}/dll_release.dll
# )
# 添加头文件路径到全局变量
# add_file(QT_THIRD_HEAD_PATH "${CMAKE_CURRENT_SOURCE_DIR}/include")
# add_file(QT_THIRD_LIBS dll)

# 在main程序中调用
# target_link_libraries(app dll)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib/include)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/dll/libusb-1.0.dll)
add_file(QT_THIRD_LIBS ${CMAKE_CURRENT_SOURCE_DIR}/dll/libusb-1.0.dll)
add_file(QT_THIRD_HEAD_PATH "${CMAKE_CURRENT_SOURCE_DIR}/include")


#add_library(dll SHARED IMPORTED GLOBAL)

#set_target_properties(dll PROPERTIES
#    # 指向lib，windows必须设置此项
##    IMPORTED_IMPLIB ${CMAKE_CURRENT_LIST_DIR}/dll.lib
#    # 指向dll、so等
#    IMPORTED_LOCATION ${CMAKE_CURRENT_LIST_DIR}/dll/libusb-1.0.dll
#)

#add_file(QT_THIRD_HEAD_PATH "${CMAKE_CURRENT_SOURCE_DIR}/include")
#add_file(QT_THIRD_LIBS dll)

